package com.helloniu.wb.tools {

import com.helloniu.data.wb.RectStyle;
import com.helloniu.data.wb.WBColor;
import com.helloniu.wb.containers.ShapeTypeDef;

import flash.geom.Rectangle;

public class RRectangleTool extends RectangularTool {
    public function RRectangleTool() {
        super();

        this.setShapeType(ShapeTypeDef.RRECT);
    }

    override protected function drawRectangularShape():void {
        if(getCurrWBStyle() is RectStyle) {
            setWBStyle(getCurrWBStyle());
        }

        var lineColor:WBColor = (getWBStyle() as RectStyle).lineColor;
        var lineWidth:uint = (getWBStyle() as RectStyle).lineWidth;
        var fillColor:WBColor = (getWBStyle() as RectStyle).fillColor;
        var rect:Rectangle = calculateRect();

        graphics.clear();
        graphics.lineStyle(lineWidth, lineColor.color, lineColor.alpha);
        graphics.beginFill(fillColor.color, fillColor.alpha);
        graphics.moveTo(rect.x, rect.y);
        graphics.drawRoundRect(rect.x, rect.y, rect.width, rect.height, 10, 10);
        graphics.endFill();
    }
}
}